//检索
function searchs() {
    top.jzts();
    $("#form").submit();
}

//详情
function detail(id) {
    top.jzts();
    var diag = new top.Dialog();
    diag.Drag = true;
    diag.Title = "详情";
    diag.URL = path + '/admin/circleRuleConfig/detailPage?id='+ id;
    diag.Width = 1050;
    diag.Height = 580;
    diag.CancelEvent = function(){ //关闭事件
        diag.close();
    };
    diag.show();
}

//新增
function add(currentPage) {
    var flag = validateAdd();
    if (flag) {
        top.jzts();
        var diag = new top.Dialog();
        diag.Drag = true;
        diag.Title ="新增";
        diag.URL = path + '/admin/circleRuleConfig/addPage';
        diag.Width = 1050;
        diag.Height = 580;
        diag.CancelEvent = function(){//关闭事件
            if(diag.innerFrame.contentWindow.document.getElementById('zhongxin').style.display == 'none'){
                if(currentPage == '0'){
                    top.jzts();
                    setTimeout("self.location=self.location",100);
                }else{
                    nextPage(currentPage);
                }
            }
            diag.close();
        };
        diag.show();
    }
}

//如果已经新增了1条配置数据，那么就不再允许新增新的配置数据
function validateAdd() {
    var flag = true;//允许新增
    $.ajax({
        url : path + "/admin/circleRuleConfig/validateAdd",
        type : "post",
        dataType : "json",
        async : false,
        success : function (data) {
            if (data.code == 400) {
                flag = false;//不允许新增
                top.hangge();
                bootbox.dialog({
                    message: "<span class='bigger-110'>" + data.msg + "</span>",
                    buttons: {
                        "button" : {
                            "label" : "确定",
                            "className" : "btn-sm btn-success"
                        }
                    }
                });
            }
        }
    });
    return flag;
}

//编辑
function edit(id, currentPage) {
    top.jzts();
    var diag = new top.Dialog();
    diag.Drag = true;
    diag.Title ="编辑";
    diag.URL = path + '/admin/circleRuleConfig/editPage?id=' + id;
    diag.Width = 1050;
    diag.Height = 580;
    diag.CancelEvent = function(){//关闭事件
        if(diag.innerFrame.contentWindow.document.getElementById('zhongxin').style.display == 'none'){
            if(currentPage == '0'){
                top.jzts();
                setTimeout("self.location=self.location",100);
            }else{
                nextPage(currentPage);
            }
        }
        diag.close();
    };
    diag.show();
}


